package woniuxy.dao;


import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;
import woniuxy.model.Country;

/**
 * ClassName:CountryMapper
 * Package:dao
 *
 * @date:2021/11/1 8:19 下午
 * @author: Tiangle
 */
public interface CountryMapper {
    @Select("select * from country where code = #{code}")
    Country getCountry(String code);//查城市时调用此方法

    @Select("select * from country where code = #{code}")
    @Results(
            value = {
                    @Result(column = "Code",property = "Code"),
                    @Result(column = "code",property = "cities",
                            many = @Many(select = "woniuxy.dao.CityMapper.getCityByCountry",fetchType = FetchType.LAZY))
            }

    )
    Country getCountryAndCity(String code);//根据国家查城市
}
